<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item label="锁定时间" prop="time">
        <el-date-picker
          v-model="formInline.time"
          type="datetimerange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
          :default-time="['00:00:00', '23:59:59']"
          :picker-options="pickerWeekStep">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="账户名" prop="username">
        <el-input v-model="formInline.username" placeholder="请输入关键词" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
      <!--<el-form-item label="账户类型" prop="userType">-->
      <!--<el-select v-model="formInline.userType" placeholder="请选择账户类型">-->
      <!--<el-option-->
      <!--v-for="item in consts.ACCOUNT_TYPE"-->
      <!--:label="item.title"-->
      <!--:key="item.value"-->
      <!--:value="item.value"-->
      <!--&gt;</el-option>-->
      <!--</el-select>-->
      <!--</el-form-item>-->
      <el-form-item label="锁定方式" prop="optType">
        <el-select v-model="formInline.optType" placeholder="请选择锁定方式">
          <el-option
            v-for="item in consts.MEMBER_LOCK_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="申请人" prop="creator">
        <el-select v-model="formInline.creator" placeholder="请选择申请人">
          <el-option label="全部" :value="undefined"></el-option>
          <el-option
            v-for="item in operatorList"
            :label="item"
            :key="item"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button class="filter-item"
                 type="primary"
                 :loading="loading"
                 icon="el-icon-search"
                 @click="$emit('on-filter',formInline)">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
  import {getAuditApplierList} from "@/services/api/audit";
  import {form, grid, pickerOption} from '@/build'

  export default {
    name: "form-filter",
    mixins: [form, grid, pickerOption],
    data() {
      return {
        operatorList: [],
        formInline: {
          time: [moment().startOf('isoWeek').format('YYYY-MM-DD 00:00:00'), moment().format('YYYY-MM-DD 23:59:59')],
          username: undefined,
          userType: 0,//0-会员，1-代理
          optType: undefined,
          creator: undefined,
        },
      }
    },
    methods: {
      selfResetForm(formName) {
        this.resetForm(formName)
        this.$emit('on-filter', this.formInline)
      }
    },
    mounted() {
      this.bindGet(getAuditApplierList, 'operatorList', {
        sendingData: {status: -1}
      });
      this.getAll()
    }
  }
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 160px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
